<template>
    <div>
        <h1>11111111111</h1>
      <el-form :model="book" label-width="80px" ref="bookForm" @submit.prevent="submitForm">
        <el-form-item label="图书编号" prop="bookId">
          <el-input v-model="book.bookId" :readonly="isEditing"></el-input>
        </el-form-item>
        <el-form-item label="图书名称" prop="bookName">
          <el-input v-model="book.bookName"></el-input>
        </el-form-item>
        <el-form-item label="作者" prop="bookAuthor">
          <el-input v-model="book.bookAuthor"></el-input>
        </el-form-item>
        <el-form-item label="评分" prop="score">
          <el-input-number v-model="book.score" :precision="1" :min="0" :max="5"></el-input-number>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm">提交</el-button>
          <el-button @click="resetForm">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
  </template>
  
  <script>
  export default {
    data() {
      return {
        book: { ...bookTemplate },
        isEditing: false // 是否处于编辑状态
      };
    },
    methods: {
      submitForm() {
        // 在这里处理提交逻辑，可以调用后端 API 保存数据等
        console.log('提交表单', this.book);
      },
      resetForm() {
        this.$refs.bookForm.resetFields();
      }
    }
  };
  </script>
  
  <style scoped>
  .add-book {
    max-width: 400px;
    margin: 0 auto;
    padding: 20px;
  }
  </style>
  